<template>
  <div>
    <h2>示例一、定义局部过滤器</h2>
    <h1>{{name | capitalize }}</h1>

    <h2>示例二、定义全局过滤器</h2>
    <div>{{ name | capitalize}}</div>

    <h2>示例三、过滤器串联</h2>
    <h1>{{name | capitalize | trim }}</h1>
  </div>

</template>

<script>

export default {



  name: 'filters',
  data () {
    return {
      name: "aitesting   ",


    }
  },

  filters: {

    //首字母大写
    capitalize (value) {
      if (!value) return ''
      value = value.toString()
      return value.charAt(0).toUpperCase() + value.slice(1)
    },

    trim (value) {
      return value.replace(/^\s+|\s+$/g, "")
    }
  },

  methods: {

  },


}
</script>


<style scoped>
</style>
